package bit.minisys.minicc.scanner;

import MyScanner.C_CodeScanner;
import bit.minisys.minicc.MiniCCCfg;
import bit.minisys.minicc.internal.util.MiniCCUtil;

public class C_JavaScaner implements IMiniCCScanner{

    @Override
    public String run(String iFile) throws Exception {
        C_CodeScanner scanner = new C_CodeScanner(iFile);
        scanner.run();
        String[] tokens = scanner.getTokensArray();
        StringBuilder strBuilder = new StringBuilder();
        for(String token : tokens)
        {
            strBuilder.append(token).append('\n');
        }

        String oFile = MiniCCUtil.removeAllExt(iFile) + MiniCCCfg.MINICC_SCANNER_OUTPUT_EXT;
        MiniCCUtil.createAndWriteFile(oFile, strBuilder.toString());
        return oFile;
    }
}
